import signal
import sys, os, time


def onexit(signum, frame):
    print('exit')
    sys.exit(0)


def main(pid):
    print('main')
    for i in range(100):
        print(i)
        if i == 10:
            exec('import os')
            exec(f'os.kill({pid},signal.SIGUSR1)')
        time.sleep(1)


if __name__ == '__main__':
    signal.signal(signal.SIGUSR1, onexit)
    pid = os.getpid()
    main(pid)
